package com.yuyu.storage.remote;

import com.yuyu.commons.interceptor.response.ResponseJson;
import com.yuyu.storage.remote.fallback.IStorageMicroServiceFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author
 * @description: 远程调用接口
 * @date: 2022/12/8 14:38
 */
@FeignClient(path = "/repository", value = "storage-service",fallbackFactory = IStorageMicroServiceFallbackFactory.class)
public interface IStorageRepositoryMicroService {

    /**
     * 远程api调用
     * @param goodsId
     * @return
     */
    @GetMapping("/getStock")
    ResponseJson<Long> getStock(@RequestParam("goodsId") Long goodsId);


    /**
     * 远程api调用减少库存
     * @param goodsId
     * @param stockNum
     * @return
     */
    @GetMapping("/decrStock")
    ResponseJson<Boolean> decStock(@RequestParam("goodsId") Long goodsId,
                                          @RequestParam("stockNum")Long stockNum);


    @GetMapping("/rollBackStock")
    ResponseJson<Boolean> rollBackStock(@RequestParam("goodsId")Long goodsId,
                                             @RequestParam("stockNum")Long stockNum);

}
